const os = require('os');

const ipconfig = [
    {
        id: 1,
        ip: "192.168.31.67",
        ip5: "192.168.2.1",
    }
];

// 获取本机ip地址
function getLocalIP() {
    const interfaces = os.networkInterfaces();
    let localIP;

    for (const key in interfaces) {
        const iface = interfaces[key];
        for (let i = 0; i < iface.length; i++) {
            const alias = iface[i];
            if (alias.family === 'IPv4' && alias.address !== '127.0.0.1' && !alias.internal) {
                localIP = alias.address;
                break;
            }
        }
        if (localIP) {
            break;
        }
    }

    return localIP;
}

module.exports = {
    ipconfig,
    getLocalIP
};
